﻿//-----------------------------------------------------------------------
// <copyright file="ITypeAdapter.cs" company="ET">
//     Copyright Huirui. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace Huirui.Cavan.Infrastructure.CrossCutting
{
    /// <summary>
    /// Base contract for map dto to aggregate or aggregate to dto.
    /// </summary>
    public interface ITypeAdapter
    {
        /// <summary>
        /// Adapts the specified source.
        /// </summary>
        /// <typeparam name="TSource">The type of the source.</typeparam>
        /// <typeparam name="TTarget">The type of the target.</typeparam>
        /// <param name="source">The source.</param>
        /// <returns>Return target value</returns>
        TTarget Adapt<TSource, TTarget>(TSource source)
            where TTarget : class,new()
            where TSource : class;

        /// <summary>
        /// Adapts the specified source.
        /// </summary>
        /// <typeparam name="TTarget">The type of the target.</typeparam>
        /// <param name="source">The source.</param>
        /// <returns>Return target value</returns>
        TTarget Adapt<TTarget>(object source)
            where TTarget : class,new();
    }
}
